<%--
  author lijiajun
  
  Date 2018/07/28
--%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>User Add</title>

<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">

  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
  
<script type="text/javascript">
	//验证用户
	function checkUserByname() {
		
		var param = {
				userName: $("#userName").val()
		}
		
		$.ajax({
			//contentType:'application/json;charset=UTF-8',
			timeout : 20000,
			type : "POST",
			dataType : "JSON",
			url : "/HMInfomation/user/queryUserByName",
			data : param,
			success : function(data) {
				//用户名校验成功
				if (data) {
					//没查到
					 $("#checkUserName").html(""); 
					 $("#submit_btn").attr("disabled",false);
				}else{
					//提示重复
					 $("#checkUserName").html("用户名已被占用！"); 
					 $("#submit_btn").attr("disabled",true);
				}
			}

		});  
		
	}
 
</script> 
  
<script type="text/javascript">
	//验证密码
	function checkUserpsw() {
		
		var password = $("#password").val().length;//获取文本框的值
		
		if(password=0 || password<6 || password>=17){
			$("#checkpsw").html("密码位数不能小于6位，不能大于16位。请重新输入！");
			$("#submit_btn").attr("disabled",true);
		}else{
			$("#checkpsw").html("");
			$("#submit_btn").attr("disabled",false);
		}
	}

</script>  
  
</head>
<body>
<div class="container">
  <h1>Add User</h1>
  <hr/>
	
  <form action="user/addUser" method="post" >
    <div class="form-group">
      <label for="userName">UserName:</label>
      <input type="text" class="form-control" id="userName" name="userName" placeholder="Enter UserName" onkeyup="checkUserByname()"/>
      <label id="checkUsername" style="color: green;"></label>
      <label id="checkUserName" style="color: red;"></label>	 
    </div>
    <div class="form-group">
      <label for="password">Password:</label>
      <input type="password" class="form-control" id="password" name="passWord" placeholder="Enter Password:" onkeyup="checkUserpsw()"/>
      <label id="checkpsw" style="color: red;"></label>
    </div>
 
    <div class="form-group">
      <button type="submit" class="btn btn-sm btn-success" id="submit_btn">Sign up</button>
    </div>
  </form>
</div>

</body>

<!-- Bootstrap core JavaScript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</html>